<template>
  <div>这里是登录</div>
  <button @click="handleLogin">点击登录</button>
</template>
<script>
import { useStore } from "vuex";
import { useRouter } from "vue-router";
export default {
  setup() {
    const store = useStore();
    const router = useRouter();
    function handleLogin() {
      store.dispatch("login").then(() => {
        window.localStorage.setItem("token", "token");
        router.push({
          path: "/home",
        });
      });
    }
    return {
      handleLogin,
    };
  },
};
</script>
